// JavaScript Document
function onReadyState()
{

	var data=null;

	//alert('AAAAAAAAAAAAAAAA');
	if(req.readyState==READY_STATE_COMPLETE)
	{ 	//setTimeout("callthis()",5000)
	
		var xmlDoc = req.responseText; //receives the response text from back page
		
		var pos=xmlDoc.indexOf('^');
		var len=xmlDoc.length;
		var content=xmlDoc.substring(0,pos);
		var num=xmlDoc.substring(pos+1,len);
		
		//alert(xmlDoc);
		//setTimeout("alert('5 seconds!')",5000)
		
		num1=num.split(':');
		//alert(num);
		//alert(num1);
		if(num==1)
		{

			var srcObj1=document.getElementById('stateId');
			srcObj1.options.length = 0 ;
	
			var statelist=content.split("_");
			//alert(statelist.length);
			for(i=0;i<statelist.length;i++)
			{
			var stateId=statelist[i].split(",");
			//alert("stId "+stateId[0]);
			document.getElementById('stateId').options[i]=new Option(stateId[1],stateId[0]);
			}
		}
		
		else if(num==2)
		{
			document.getElementById('channels_module').style.display='';
			document.getElementById('channels_module').innerHTML = content;
		}

		else if(num==3)
		{
			document.getElementById('custom_targeting').style.display='';
			document.getElementById('custom_targeting').innerHTML = content;
		}

		else if(num==4)
		{
			document.getElementById('all_channels_ajax').style.display='';
			document.getElementById('all_channels_ajax').innerHTML = content;
		}

		else if(num==5)
		{
			//document.getElementById('all_channels_ajax').style.display='';
			document.getElementById('review_targeting').innerHTML = content;
		}

		else if(num==6)
		{
			var arr=content.split(":");
			//alert(arr[0]);
			//alert(arr[1]);
			//alert(arr[2]);
			document.getElementById('approved_'+arr[1]).style.display='';
			document.getElementById('approved_'+arr[1]).innerHTML = arr[0];


				document.getElementById('action_'+arr[1]).style.display='';
				document.getElementById('action_'+arr[1]).innerHTML = arr[2];

		}

		else if(num==7)
		{
 			var arrr=content.split(":");
 			alert(arrr[0]);
 			alert(arrr[1]);
 			alert(arrr[2]);
			alert(arrr[3]);
 			document.getElementById('adgroup_approved_'+arrr[1]+arrr[2]).style.display='';
 			document.getElementById('adgroup_approved_'+arrr[1]+arrr[2]).innerHTML = arrr[0];
 
 
 			document.getElementById('adgroup_action_'+arrr[1]+arrr[2]).style.display='';
 			document.getElementById('adgroup_action_'+arrr[1]+arrr[2]).innerHTML = arrr[3];

		}

		else if(num==8)
		{
 			var arr=content.split(":");
 			alert(arr[0]);
			alert(arr[1]);
			alert(arr[2]);
			alert(arr[3]);
			alert(arr[4]);
 			document.getElementById('adgroup_ad_approved_'+arr[1]+arr[2]+arr[3]).style.display='';
 			document.getElementById('adgroup_ad_approved_'+arr[1]+arr[2]+arr[3]).innerHTML = arr[0];
 
 
 			document.getElementById('adgroup_ad_action_'+arr[1]+arr[2]+arr[3]).style.display='';
 			document.getElementById('adgroup_ad_action_'+arr[1]+arr[2]+arr[3]).innerHTML = arr[4];

		}
		else if(num==9)
		{
			//alert('jishnu');
 			top.document.getElementById('adgroup_network').style.display='';
 			top.document.getElementById('adgroup_network').innerHTML = content;
			document.getElementById('frmTargets').submit();
		}

		else if(num==10)
		{
			//alert('123');
			//alert(content);
			var adgroup=content.split("~~~~~");
			//alert('hh'+adgroup[0]);
			//alert(adgroup[1]);
 			top.document.getElementById('adgroup_network'+adgroup[1]).style.display='';
 			top.document.getElementById('adgroup_network'+adgroup[1]).innerHTML = adgroup[0];
			document.getElementById('frmTargets').submit();
		}
	}
}
// function callthis()
// 	{
// 		return 0;
// 	}